package com.edu.video.controller;


import com.edu.entity.HfdVideoInfo;
import com.edu.video.service.IHfdVideoInfoService;
import com.edu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;

/**
 * <p>
 * 视频表 前端控制器
 * </p>
 *
 * @author jr
 * @since 2021-04-16
 */
@RestController
@RequestMapping("/video")
public class HfdVideoInfoController {

    @Autowired
    private IHfdVideoInfoService hfdVideoInfoService;

    /**
     * 添加视频
     *
     * @param hfdVideoInfo
     * @return
     */
    @RequestMapping("addVideo")
    public Result addVideo(@RequestBody HfdVideoInfo hfdVideoInfo) {
        return hfdVideoInfoService.addVideo(hfdVideoInfo);
    }

    /**
     * 查询所有视频信息
     *
     * @return
     */
    @RequestMapping("queryVideo")
    public Result queryVideo() {
        return hfdVideoInfoService.queryVideo();
    }

    /**
     * 根据video_id删除视频
     *
     * @return
     */
    @RequestMapping("deleteVideoById")
    public Result deleteVideoById(String videoId) {
        return hfdVideoInfoService.deleteVideoById(videoId);
    }

    /**
     * 根据video_id修改视频信息
     *
     * @param hfdVideoInfo
     * @return
     */
    @RequestMapping("updateVideoById")
    public Result updateVideoById(@RequestBody HfdVideoInfo hfdVideoInfo) {
        return hfdVideoInfoService.updateVideoById(hfdVideoInfo);
    }

    @RequestMapping("uploadVideo")
    public Result uploadVideo(@RequestBody HfdVideoInfo hfdVideoInfo) {
        return hfdVideoInfoService.uploadVideo(hfdVideoInfo);
    }

    @RequestMapping("getVideoBySkuId")
    public Result getVideoBySkuId(@PathParam("skuId") Integer skuId){
        return hfdVideoInfoService.getVideoBySkuId(skuId);
    }
}
